#pragma once

#include <memory>
#include <vector>

#include "LogEvent.h"

namespace bamboo {

class LogEvent;

class LogMsg {
public:
    enum Msg {
        CONTENT = 1,    //消息
        LEVEL,          //日志级别
        ELAPSE,         //累计毫秒数
        NAME,           //日志名称
        THREADID,       //线程id
        NEWLINE,        //换行
        DATETIME,       //时间
        FILENAME,       //文件名
        LINENUM,        //行号
        TAB,            //tab
        FIBERID,        //协程id
        THREADNAME,     //线程名称
    };
};

class FormatItem {
public:
    typedef std::shared_ptr<FormatItem> ptr;
    virtual ~FormatItem() {}
    virtual std::string format(LogEvent::ptr event) = 0;
};

//控制日志输出格式
class LogFormatter {
public:
    typedef std::shared_ptr<LogFormatter> ptr;

    //%t %thread_id
    std::string format(LogEvent::ptr event);
    void addMsg(LogMsg::Msg msg);
private:
    std::vector<FormatItem::ptr> m_items;
};

} // namespace bamboo